/*
 * Copyright (c) 2007-2020 西安交通信息投资营运有限公司 版权所有
 * 作者:马星俊
 */

import React from 'react';
import {Tree} from "antd";

export interface ParamProps {
  treeData: { tree: [], checks: [] };
  onChange: (keys: any) => void;
}

const DeptTree: React.FC<ParamProps> = (props) => {
  const {treeData, onChange} = props;
  const onclick = (checkedKeys: any) => {
    onChange([...checkedKeys])
  }

  return (
    <div>
      {treeData && treeData.tree.length ? (
        <Tree
          style={{maxHeight: '300px', padding: "10px 5px", overflowY: 'auto'}}
          checkable
          defaultExpandAll
          treeData={treeData.tree}
          defaultCheckedKeys={treeData.checks}
          onCheck={onclick}
        />
      ) : null}
    </div>
  );
};

export default DeptTree;
